package org.jiangpz.excel.merge.process;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import org.jiangpz.excel.merge.entity.RowEntity;

public class Util {
	
	public static RowEntity setValue (RowEntity rowEntity, int j, Double cellVal) {
		char A = 'A';
		
		String methodName = "set" + (char)((int)A + j);
		Method method = null;
		try {
			method = rowEntity.getClass().getDeclaredMethod(methodName, new Class[]{Double.class});
		} catch (NoSuchMethodException e) {
			System.out.println("获取方法出错");
			e.printStackTrace();
		} catch (SecurityException e) {
			System.out.println("获取方法出错");
			e.printStackTrace();
		}
		try {
			method.invoke(rowEntity, new Object[]{cellVal});
		} catch (IllegalAccessException e) {
			System.out.println("调用出错");
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			System.out.println("调用出错");
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			System.out.println("调用出错");
			e.printStackTrace();
		}
		
		return rowEntity;
	}
	
}
